<template>
  <div class="wrap">
    <div class="hd flex">
      <h3>{{ hTitle }}</h3>
      <div class="count">{{ todoListArr.length }}</div>
    </div>
    <TodoListItem v-for="item in todoListArr" :key="item.id" :data="item">
      <!-- 编辑 -->
      <input
        type="button"
        value="编辑"
        slot="editSlot"
        @click="edit(item.id)"
      />
      <!-- 删除 -->
      <input type="button" value="删除" slot="delSlot" @click="del(item.id)" />
    </TodoListItem>
  </div>
</template>
<script>
import TodoListItem from "@/components/TodoListItem.vue";
export default {
  components: {
    TodoListItem,
  },
  props: ["h-title", "todoListArr"],
  methods: {
    del(id) {
      this.$store.commit("delItem", id);
    },
    edit(id) {
      this.$store.commit("editItem", id);
    },
  },
  
};
</script>
 
<style>
.hd {
  justify-content: space-between;
  margin: 5px 0;
}

.count {
  width: 30px;
  height: 30px;
  background-color: #ccccff;
  border-radius: 50%;
  text-align: center;
  line-height: 30px;
}
</style>